package fischl;

import com.google.gson.Gson;
import fischl.douyuApi.DouyuApi;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

import java.util.concurrent.TimeUnit;

public final class Global {
  private static final OkHttpClient okHttpClient = new OkHttpClient.Builder()
    .readTimeout(25, TimeUnit.SECONDS)//有时候弹幕处理的很慢，这里延长read超时时间
    .build();
  private static final Gson gson = new Gson();
  private static final Retrofit retrofit = new Retrofit.Builder()
    .baseUrl("https://v.douyu.com/wgapi/vod/center/")
    .addConverterFactory(GsonConverterFactory.create(gson))
    .build();
  private static DouyuApi douyuApi;

  public static OkHttpClient okHttpClient() {
    return okHttpClient;
  }

  public static Gson gson() {
    return gson;
  }

  public static DouyuApi douyuApi() {
    if (douyuApi == null) {
      douyuApi = retrofit.create(DouyuApi.class);
    }
    return douyuApi;
  }

}
